/*
 * Author:          Xiaosi Xu
 * Written:         2/10/2014
 * Last Updated:    2/10/2014
 * 
 * Materials that used to cook a dish
 * Each dish has its own ingredients and amount requirement about ingredients.
 */

package JavaSource;

import java.io.Serializable;

/**
 *
 * @author Xiaosi Xu
 * @version 1.0
 */
public class Ingredient implements Serializable,IdGenerable{
    
    //Attribute
    private static int globalId=5000;
    private int ingredientId;
    private String name;
    private int amount;  // ingredient amount for specific dish
    private int quantity;  // quantity of the ingredient in the restaurant
    private double threshold; // The minimun amount that the ingredient could be used to cook a dish
    private Ingredient wareHouseIngredient;
    
    
    
    //Constructor
    public Ingredient(int quantity, String name){
        this.ingredientId = generateId();
        this.quantity = quantity;
        this.name = name;
    }
    
    public Ingredient(int amount, Ingredient wIngredient){
        
        wareHouseIngredient = wIngredient;
        this.quantity = wIngredient.quantity;
        this.name = wIngredient.name;
        this.amount = amount;
    }
    
    //Method
    
    public static int getGlobalId() {
        return globalId;
    }

    public static void setGlobalId(int globalId) {
        Ingredient.globalId = globalId;
    }
    
    public int getIngredientId() {
        return ingredientId;
    }

    public void setIngredientId(int ingredientId) {
        this.ingredientId = ingredientId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public double getThreshold() {
        return threshold;
    }

    public void setThreshold(double threshold) {
        this.threshold = threshold;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public Ingredient getWareHouseIngredient() {
        return wareHouseIngredient;
    }

    public void setWareHouseIngredient(Ingredient wareHouseIngredient) {
        this.wareHouseIngredient = wareHouseIngredient;
    }

    public boolean checkIngredientAvailability(){
    
        if(this.getWareHouseIngredient().getQuantity()>this.getWareHouseIngredient().getThreshold()){return true;}
    else return false;
    }
    
    @Override
    public int generateId() {
        return ++globalId;
    }
    

    
    
    
    
    
}
